<template>
    <FormItem :label="`${itemData.label}：`" :prop="itemData.name" :label-for="itemData.name" :rules='itemData.rules'>
				<!-- <div class="qw-form-txt" v-if="itemData.readonly">{{ itemData.label }}</div>

				<Cascader v-else :disabled="itemData.disabled" v-model='formData[itemData.name]' :data="selectData" :load-data="getCityData" @on-change='handleChange' :filterable="itemData.filterable"></Cascader> -->
				<!-- <Cascader v-else :disabled="itemData.disabled" v-model="formData[itemData.name]" @on-change='handleChange' :data="itemData.areaData" :changeOnSelect="itemData.changeOnSelect" :filterable="itemData.filterable"></Cascader> -->
    </FormItem>
</template>
<script>
    import { ApiRequest } from '@api/basePage';
    export default {
        props: {
            itemData: {
                type: Object
            },
            formData: {
                type: Object
            },
            getName: {
                type: Boolean,
                default: false
            }
        },
        data () {
            return {
                dataList: [],
                selectData: [],
                nameArr: [],
                // 列表页请求接口地址
                requestApi: { // 视情况自定义
                    // 获取分类
                    getClassify: {
                        url: '/sysback/template/producttemplatecategrory/getAllTemplateCategroy', // 接口地址
                        type: 'post' // 接口请求类型
                    }
                }
            };
        },
        watch: {
            itemData (val) {
                if (this.getName) {
                    this.formData.cityNames = [];
                    this.$emit('handleChangeFormData', this.formData);
                }
            }
        },
        created () {
            this.getClassify();
        },
        methods: {
            // 改变选中值
            handleChange (value, selectData) {
                let nameArr = [];
                selectData.forEach(item => {
                    nameArr.push(item.label)
                })
                if (this.getName) {
                    this.formData.cityNames = nameArr;
                    this.$emit('handleChangeFormData', this.formData);
                    this.$emit('getCityName', nameArr);
                } else {
                    this.$emit('handleChangeFormData', this.formData);
                }
            },
            // 获取省
            getClassify () {
                let data = {}
                // 开始请求商品列表
                ApiRequest(this.requestApi.getClassify.url, this.requestApi.getClassify.type, data).then(res => {
                    // if (res.retStatus === '1') {
                    //     this.allProvice = res.retData

                    //     this.allProvice.forEach(item => {
                    //         this.selectData.push({
                    //             level: '1',
                    //             value: item.areaCode,
                    //             label: item.provinceName,
                    //             children: [],
                    //             loading: false
                    //         })
                    //     })
                    // }
                })
            }

        }
    }
</script>
